<!-- 这是图片分享详情的组件 -->
<template>
<div>
    <h4>{{title}}</h4>
    <p><span class="time">发表时间: {{time.split('T')[0]}}</span><span class="click">点击: 0</span></p>
    <hr>
    <ul>
        <li v-for="item in imgList" :key="item.id">
            <img :src="item.src" @click="bigImg">
        </li>
    </ul>
    <div class="detail-content" v-html="imgDetails"></div>
    <comment></comment>
</div>
</template>

<script>
import { ImagePreview } from 'vant'
import Axios from 'axios'
import Comment from './Review.vue'
export default {
  components: {
    comment: Comment
  },
  created () {
    var detailsid = window.localStorage.getItem('id')
    Axios.get('/api/getthumimages/' + detailsid).then(res => {
      console.log(res)
      this.imgList = res.data.message
      this.imgList.forEach(ele => {
          this.imgArr.push(ele.src)
      })
    })
    Axios.get('/api/getimageInfo/' + detailsid).then(res => {
      console.log(res)
      this.title = res.data.message[0].title
      this.imgDetails = res.data.message[0].content
      this.time = res.data.message[0].add_time
    })
  },
  data () {
    return {
      imgList: [],
      title: '',
      imgDetails: '',
      time: '',
      imgArr: []
    }
  },
  methods: {
    bigImg() {
        ImagePreview({
            images: this.imgArr,
            closeable: true
        })
    }
  }
}
</script>

<style scoped>
h4{
    text-align: center;
    color: #26a2ff;
    font-size: 15px;
}
p{
    overflow: hidden;
}
.time{
    float: left;
    font-size: 13px;
    color: #8f8f94;
}
.click{
    float: right;
    font-size: 13px;
    color: #8f8f94;
}
ul{
    list-style: none;
    margin: 10px 0;
    padding: 0 5px;
    overflow: hidden;
}
li{
    float: left;
    width: 33.3333%;
    padding: 5px;
    box-sizing: border-box;
}
ul li img{
    width: 100%;
    box-shadow: 1px 0 8px 1px rgba(0,0,0,.3);
}
.van-cell-group {
    background-color: #fff;
}
.van-field{
    height: 100px;
    border: 1px solid #ccc;
}
.van-cell__value--alone {
    color: #323233;
    text-align: left;
}
.van-field__control {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 0;
    color: #323233;
    text-align: left;
    background-color: transparent;
    border: 0;
    resize: none;
}
.van-button{
    width: 100%;
    margin: 5px 0;
}
.van-button--normal {
    padding: 0 15px;
    font-size: 14px;
}
.van-button--info {
    color: #fff;
    background-color: #1989fa;
    border: 1px solid #1989fa;
}
.van-button {
    position: relative;
    display: inline-block;
    box-sizing: border-box;
    height: 44px;
    line-height: 42px;
    text-align: center;
    border-radius: 2px;
}
.van-button:before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-color: #000;
    border: inherit;
    border-color: #000;
    border-radius: inherit;
    transform: translate(-50%,-50%);
    opacity: 0;
    content: " ";
}
.title{
    height: 30px;
    background-color: #ccc;
    font-size: 12px;
    line-height: 30px;
}
.title span{
    margin-right: 6px;
}
.title{
    height: 30px;
    background-color: #ccc;
    font-size: 12px;
    line-height: 30px;
}
.body{
    line-height: 35px;
    text-indent: 2em;
    font-size: 12px;
}
.van-list__placeholder {
    height: 0;
    pointer-events: none;
}
</style>
